package com.tangzhe.service;

import com.tangzhe.dao.StudentMapper;
import com.tangzhe.entity.Student;
import com.tangzhe.entity.StudentExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    /**
     * 查询所有学生
     */
    @Transactional(noRollbackFor = RuntimeException.class)//不受检查的异常，可以不用处理
    //@Transactional(propagation = Propagation.REQUIRED)
    public List<Student> findAll() {
        StudentExample example = new StudentExample();
        List<Student> students = studentMapper.selectByExample(example);
        return students;
    }
}
